-
Notifications
You must be signed in to change notification settings - Fork 87
Fix: Remove incorrect 'Closed' label for merged PRs in reviewed section #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR refactors the logic for labeling “closed” PR items in the reviewed section by explicitly fetching and evaluating merge status, rendering distinct labels for merged, closed, or defaulting unknown states to an open label. Class diagram for PR status labeling logic in reviewed sectionclassDiagram
class PRItem {
+string state
+string repository_url
+int number
+string html_url
+string title
}
class PRStatusLabeler {
+labelPR(PRItem item, mergedStatusResults, githubToken, useMergedStatus, fallbackToSimple)
}
PRStatusLabeler ..> PRItem : uses
class MergedStatusResults {
+map<string, bool> mergedStatus
}
PRStatusLabeler ..> MergedStatusResults : queries
Flow diagram for PR status label selection in reviewed sectionflowchart TD
A[PR state is 'closed'] --> B{Fetch merged status}
B -->|merged === true| C[Show 'Merged' label]
B -->|merged === false| D[Show 'Closed' label]
B -->|merged is null/undefined| E[Show 'Open' label]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @manhuu14 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/scripts/scrumHelper.js:977` </location>
<code_context>
li += `</li>`;
- } else if (item.state === 'closed') {
- let merged = null;
- if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
- let repoParts = repository_url.split('/');
- let owner = repoParts[repoParts.length - 2];
- let repo = repoParts[repoParts.length - 1];
- merged = mergedStatusResults[`${owner}/${repo}#${number}`];
- }
- if (merged === true) {
</code_context>
<issue_to_address>
Potential edge case if repository_url is malformed.
Accessing array indices after splitting repository_url may cause errors if the URL is malformed. Add validation or guards to handle unexpected input.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @manhuu14 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/scripts/scrumHelper.js:985` </location>
<code_context>
+ } else if (merged === false) {
+ // PR is confirmed closed but not merged
+ li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_closed_button}</li>`;
+ } else {
+ // merged === null/undefined - status unknown
+ // For reviewed PRs section, we should be more conservative about showing "closed"
+ // since these aren't the user's PRs. Default to showing no specific state label
+ // or a neutral label instead of assuming "closed"
+ li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_open_button}</li>`;
+
+ // Alternative approach: Don't show any state label for unknown status
</code_context>
<issue_to_address>
Defaulting to 'open' label for unknown merged status may be misleading.
Displaying 'open' when merged status is unknown may mislead users, as the PR is closed but its merged state is unclear. Consider a neutral or absent label to better reflect this ambiguity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
} else {
// merged === null/undefined - status unknown
// For reviewed PRs section, we should be more conservative about showing "closed"
// since these aren't the user's PRs. Default to showing no specific state label
// or a neutral label instead of assuming "closed"
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_open_button}</li>`;
// Alternative approach: Don't show any state label for unknown status
// li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a></li>`;
}
=======
} else {
// merged === null/undefined - status unknown
// Do not show any state label for unknown status to avoid misleading users
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a></li>`;
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/scripts/scrumHelper.js:977` </location>
<code_context>
li += `</li>`;
- } else if (item.state === 'closed') {
- let merged = null;
- if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
- let repoParts = repository_url.split('/');
- let owner = repoParts[repoParts.length - 2];
- let repo = repoParts[repoParts.length - 1];
- merged = mergedStatusResults[`${owner}/${repo}#${number}`];
- }
- if (merged === true) {
</code_context>
<issue_to_address>
Potential edge case if repository_url is malformed.
Accessing repository_url by index may fail if its structure is inconsistent. Please add validation to ensure repository_url is well-formed before splitting and accessing its parts.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
} else if (item.state === 'closed') { | ||
let merged = null; | ||
if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) { | ||
let repoParts = repository_url.split('/'); | ||
let owner = repoParts[repoParts.length - 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Potential edge case if repository_url is malformed.
Accessing repository_url by index may fail if its structure is inconsistent. Please add validation to ensure repository_url is well-formed before splitting and accessing its parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you resend the suggestion to merge this pr beacuse me bymistakely clicked resolve option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I'm generating a new review now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @manhuu14, I've posted a new review for you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (item.state === 'closed') {
const merged = getMergedStatus(item, repository_url, item.number, githubToken, useMergedStatus, fallbackToSimple, mergedStatusResults);
if (merged === true) {
// Confirmed merged
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_merged_button}</li>`;
} else if (merged === false) {
// Closed but not merged
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a> ${pr_closed_button}</li>`;
} else {
// Unknown merge status: show no state label to avoid misleading users
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a></li>`;
}
}
and function getMergedStatus(item, repository_url, prNumber, githubToken, useMergedStatus, fallbackToSimple, mergedStatusResults) {
let merged = null;
if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
try {
const parsedUrl = new URL(repository_url);
const pathParts = parsedUrl.pathname.split('/').filter(Boolean); // remove empty strings
if (pathParts.length >= 2) {
const owner = pathParts[pathParts.length - 2];
const repo = pathParts[pathParts.length - 1];
const prKey = `${owner}/${repo}#${prNumber}`;
if (mergedStatusResults.hasOwnProperty(prKey)) {
merged = mergedStatusResults[prKey]; // true, false, or undefined
}
} else {
console.warn('[scrum_helper] URL path too short to parse owner/repo:', parsedUrl.pathname);
}
} catch (err) {
console.warn('[scrum_helper] Invalid repository_url:', repository_url, err);
}
}
return merged;
}
add this and try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your latest changes and the review discussion, your PR is ready to be merged! You have addressed the feedback by making the merged status logic more robust and handling edge cases for malformed URLs. If your tests are passing and everything works as expected, you can go ahead and merge the PR.
If you need a final approval from a maintainer, just request it�otherwise, you're good to go!
Let me know if you need help with the merge process or anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i made another pr and there is no isuue ai saing all good how to request maintainer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To request a review from a maintainer on your new PR, follow these steps:
- Go to your pull request page on GitHub.
- On the right sidebar, look for the "Reviewers" section.
- Click the gear icon or the "Request" button next to "Reviewers."
- Search for the maintainer's GitHub username (or select from the list) and click their name to add them as a reviewer.
- They will be notified and can review your PR.
If you don't see the "Reviewers" section, you may not have permission to request reviewers directly. In that case, you can leave a comment on the PR mentioning the maintainer (e.g., @maintainer-username
) and politely ask them to review your PR.
Let me know if you need more help!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i leave this one automatically merge or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, your pull request will not merge automatically if you leave it (unless your repository has an auto-merge feature enabled, which is uncommon). Normally, after your PR is approved and all checks pass, someone (either you or a maintainer) needs to manually click the "Merge" button on GitHub to complete the process.
If you want your PR to be merged, make sure to:
- Get all required approvals
- Pass all required checks (like CI tests)
- Then, either merge it yourself (if you have permission) or ask a maintainer to merge it for you
Let me know if you need help with the merge process or have any other questions!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @manhuu14 - I've reviewed your changes - here's some feedback:
- Consider extracting the merged/closed/unknown labeling logic into a helper function to reduce nesting and improve readability.
- Instead of manually splitting
repository_url
, use a URL parser or regex utility to safely extractowner
andrepo
and avoid edge-case URL formats. - Double-check that defaulting unknown merge status to
pr_open_button
matches the intended UX for reviewed PRs, or consider a neutral/no‐label display instead.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the merged/closed/unknown labeling logic into a helper function to reduce nesting and improve readability.
- Instead of manually splitting `repository_url`, use a URL parser or regex utility to safely extract `owner` and `repo` and avoid edge-case URL formats.
- Double-check that defaulting unknown merge status to `pr_open_button` matches the intended UX for reviewed PRs, or consider a neutral/no‐label display instead.
## Individual Comments
### Comment 1
<location> `src/scripts/scrumHelper.js:977` </location>
<code_context>
li += `</li>`;
- } else if (item.state === 'closed') {
- let merged = null;
- if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
- let repoParts = repository_url.split('/');
- let owner = repoParts[repoParts.length - 2];
</code_context>
<issue_to_address>
The merged status lookup logic could be extracted for clarity.
Consider moving the merged status determination into a helper function to simplify the code and enhance maintainability.
Suggested implementation:
```javascript
let merged = getMergedStatus(item, repository_url, githubToken, useMergedStatus, fallbackToSimple, mergedStatusResults);
```
```javascript
```
```javascript
});
}
li += `</li>`;
function getMergedStatus(item, repository_url, githubToken, useMergedStatus, fallbackToSimple, mergedStatusResults) {
let merged = null;
if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
let repoParts = repository_url.split('/');
let owner = repoParts[repoParts.length - 2];
let repo = repoParts[repoParts.length - 1];
let prKey = `${owner}/${repo}#${item.number}`;
if (mergedStatusResults.hasOwnProperty(prKey)) {
merged = mergedStatusResults[prKey];
}
}
return merged;
}
```
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@manhuu14 Please add screenshots of the fix |
@vedansh-5 sorry for that my Laptop was not able to perform that much actions, some os problem. |
Description
Fixes the bug where merged PRs were showing "Closed" label in the reviewed PRs section.
Changes Made
Testing
Related Issue
Fixes #176
Screenshots
[Add before/after screenshots if possible]
Summary by Sourcery
Fix PR state labeling in the reviewed section to distinguish merged, closed, and unknown statuses accurately
Bug Fixes:
Enhancements: